package com.umeox.watch.moto.launcher.ui;


import android.os.Bundle;

import androidx.collection.LongSparseArray;
import androidx.fragment.app.Fragment;

import com.umeox.watch.moto.dataservice.DataProvider;
import com.umeox.watch.moto.launcher.fragment.AppListFragment;
import com.umeox.watch.moto.launcher.fragment.ChallengeFragment;
import com.umeox.watch.moto.launcher.fragment.HomeFragment;
import com.umeox.watch.moto.launcher.fragment.IdleFragment;
import com.umeox.watch.moto.launcher.fragment.NotificationFragment;
import com.umeox.watch.moto.launcher.fragment.PrayerTimeListFragment;
import com.umeox.watch.moto.launcher.fragment.QuickSettingsFragment;
import com.umeox.watch.moto.launcher.fragment.UnbindFragment;

import java.util.Arrays;
import java.util.List;


public class FragmentFactory {

    private static final LongSparseArray<Fragment> mMainFragments = new LongSparseArray<>();
    public static final String ITEM_ID = "ItemId";

    public static Fragment getFragment(int type) {

        Fragment fragment = null;
        switch (type) {
            case -1:
                fragment = new UnbindFragment();
                break;
            case 0:
                fragment = new ChallengeFragment();
                break;
            case 1:
                fragment = new IdleFragment();
                break;
            case 2:
                fragment = new AppListFragment();
                break;
            case 3:
                fragment = new QuickSettingsFragment();
                break;
            case 4:
                fragment = new HomeFragment();
                break;
            case 5:
                fragment = new NotificationFragment();
                break;
            case 6:
                fragment = new PrayerTimeListFragment();
                break;
        }
        final Bundle bundle = new Bundle();
        bundle.putLong(ITEM_ID, type);
        fragment.setArguments(bundle);
        mMainFragments.put(type, fragment);
        return fragment;
    }


    public static List<Fragment> getMainFragments() {

        if (DataProvider.isActivated()) {
            return Arrays.asList(getFragment(0),getFragment(6)
                    , getFragment(1)
                    , getFragment(2));

        }

        return Arrays.asList(getFragment(-1), getFragment(1), getFragment(2));
    }


    public static List<Fragment> getIdleFragments() {

        return DataProvider.isActivated()
                ? Arrays.asList(getFragment(3), getFragment(4), getFragment(5))
                : Arrays.asList(getFragment(3), getFragment(4));


    }

}
